package lab01;

public class Text05 {
    public static void main(String[] args) {
        forSum();
        whileSum();
        dowhileSum();
        //把for，while,dowhile写在一个程序里面，先在main函数里声明
    }
    public static void forSum(){
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            sum = sum + i;
        }
        System.out.println("sum=" + sum);
    }

    public static void whileSum(){
        int j= 1;
        int sum1=0;
        while (j<=100){
            sum1=sum1+j;
            j++;
        }
        System.out.println("sum1="+sum1);
    }
    public static void dowhileSum(){
        int k=0;
        int sum2=0;
        do{
            sum2=sum2+k;
            k++;
        }while (k<=100);
        System.out.println("sum2="+sum2);
    }
}
